<template>
  <div class="box">
    <div
      style="
        position: absolute;
        z-index: 10;
        font-size: 80px;
        right: 20px;
        top: 10px;
        color: white;
        cursor: pointer;
      "
      @click="$router.push('/')"
    >
      <el-icon><HomeFilled /></el-icon>
    </div>

    <div class="title">勋章榜</div>
    <div>
      <el-table
        :data="dataList"
        header-row-style="font-size:30px"
        row-style="height: 110px;background-color:#324374"
      >
        <el-table-column property="name" label="组名" width="130" />
        <el-table-column label="学习达人" width="150">
          <template #default="scope">
            <img
              :src="getImg(scope.row.m1)"
              alt=""
              width="90px"
              @click="() => (scope.row.m1 = scope.row.m1 == '1' ? '01' : '1')"
            />
          </template>
        </el-table-column>
        <el-table-column label="技能达人" width="150">
          <template #default="scope">
            <img
              :src="getImg(scope.row.m2)"
              alt=""
              width="90px"
              @click="() => (scope.row.m2 = scope.row.m2 == '2' ? '02' : '2')"
            />
          </template>
        </el-table-column>
        <el-table-column label="进步达人" width="150">
          <template #default="scope">
            <img
              :src="getImg(scope.row.m3)"
              alt=""
              width="90px"
              @click="() => (scope.row.m3 = scope.row.m3 == '3' ? '03' : '3')"
            />
          </template>
        </el-table-column>
        <el-table-column label="项目达人" width="150">
          <template #default="scope">
            <transition name="fade" mode="out-in">
              <img
                v-if="scope.row.m4 == '4'"
                src="../../img/medal/04.png"
                width="90px"
                @click="() => (scope.row.m4 = scope.row.m4 == '4' ? '04' : '4')"
              />
              <img
                v-else
                src="../../img/medal/4.png"
                width="90px"
                @click="() => (scope.row.m4 = scope.row.m4 == '4' ? '04' : '4')"
              />
            </transition>
          </template>
        </el-table-column>
        <el-table-column label="信息意识" width="150">
          <template #default="scope">
            <img
              :src="getImg(scope.row.m5)"
              alt=""
              width="90px"
              @click="() => (scope.row.m5 = scope.row.m5 == '5' ? '05' : '5')"
            />
          </template>
        </el-table-column>
        <el-table-column label="数字思维" width="150">
          <template #default="scope">
            <img
              :src="getImg(scope.row.m6)"
              alt=""
              width="90px"
              @click="() => (scope.row.m6 = scope.row.m6 == '6' ? '06' : '6')"
            />
          </template>
        </el-table-column>
        <el-table-column label="团队协作" width="150">
          <template #default="scope">
            <img
              :src="getImg(scope.row.m7)"
              alt=""
              width="90px"
              @click="() => (scope.row.m7 = scope.row.m7 == '7' ? '07' : '7')"
            />
          </template>
        </el-table-column>
        <el-table-column label="创新发展" width="150">
          <template #default="scope">
            <img
              :src="getImg(scope.row.m8)"
              alt=""
              width="90px"
              @click="() => (scope.row.m8 = scope.row.m8 == '8' ? '08' : '8')"
            />
          </template>
        </el-table-column>
        <el-table-column label="社会责任" width="150">
          <template #default="scope">
            <img
              :src="getImg(scope.row.m9)"
              alt=""
              width="90px"
              @click="() => (scope.row.m9 = scope.row.m9 == '9' ? '09' : '9')"
            />
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { HomeFilled } from "@element-plus/icons-vue";

const dataList = ref([
  {
    id: "1",
    name: "知行组",
    m1: "01",
    m2: "02",
    m3: "03",
    m4: "4",
    m5: "5",
    m6: "6",
    m7: "07",
    m8: "8",
    m9: "9",
  },
  {
    id: "2",
    name: "好学组",
    m1: "01",
    m2: "02",
    m3: "03",
    m4: "04",
    m5: "05",
    m6: "6",
    m7: "07",
    m8: "8",
    m9: "9",
  },
  {
    id: "3",
    name: "善学组",
    m1: "01",
    m2: "02",
    m3: "03",
    m4: "4",
    m5: "05",
    m6: "06",
    m7: "07",
    m8: "08",
    m9: "9",
  },
  {
    id: "4",
    name: "崇学组",
    m1: "01",
    m2: "02",
    m3: "03",
    m4: "4",
    m5: "05",
    m6: "6",
    m7: "07",
    m8: "8",
    m9: "09",
  },
  {
    id: "5",
    name: "思行组",
    m1: "01",
    m2: "02",
    m3: "3",
    m4: "04",
    m5: "05",
    m6: "06",
    m7: "07",
    m8: "08",
    m9: "09",
  },
  {
    id: "6",
    name: "力行组",
    m1: "01",
    m2: "02",
    m3: "03",
    m4: "04",
    m5: "05",
    m6: "06",
    m7: "07",
    m8: "8",
    m9: "09",
  },
]);

const getImg = (m) => {
  if (m == null) {
    return require(`../../img/medal/04.png`);
  }

  return require(`../../img/medal/${m}.png`);
};
</script>

<style scoped lang="scss">
.box {
  height: calc(100vh - 10px);
  background-color: #2d4351;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  .title {
    width: 500px;
    height: 100px;
    color: #fff;
    font-size: 60px;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 100px;
    text-align: center;
    color: white;
    border-radius: 15px;
    background-color: #81429e;
    box-shadow: 0 0 5px 3px rgb(0, 0, 0);
    margin: 10px;
    margin-bottom: 30px;
  }

  .el-table {
    font-size: 30px;
    width: 100%;
    font-weight: 600;
    --el-table-border-color: black;
    --el-table-row-hover-bg-color: #6173a8;
    --el-table-header-bg-color: #324374;
  }
}

:deep .cell {
  line-height: 30px;
  color: white;
  text-align: center;
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.fade-enter-to,
.fade-leave-from {
  opacity: 1;
}

img {
}
</style>